#ifndef		__CONFIG_H
#define		__CONFIG_H
#include "ti_msp_dl_config.h"
//========================================================================
//                               主时钟定义
//========================================================================
#define SYS_VOL 3.3  	//系统工作电压（V）

#define MAIN_Fosc		        	CPUCLK_FREQ	//来自ti_msp_dl_config.h的主时钟定义

// delay函数已经重置目前没找到下列宏定义被引用的位置。
// #define Main_Fosc2	(MAIN_Fosc / 2)  //主时钟/2
// #define Main_Fosc4	(MAIN_Fosc / 4)  //主时钟/4
// #define Main_Fosc8	(MAIN_Fosc / 8)  //主时钟/8
// #define Main_Fosc16	(MAIN_Fosc / 16)  //主时钟/16
// #define Main_Fosc_KHZ	(MAIN_Fosc / 1000)  //主时钟KHZ
// #define Main_Fosc_MHZ	(MAIN_Fosc / 1000000)  //主时钟MHZ
//                             数据类型宏定义
//========================================================================
#ifndef NULL
 #define NULL ((void *) 0)
#endif
 
typedef unsigned char BYTE;
typedef unsigned int WORD;
typedef unsigned long DWORD;

#define max(A,B) ((A)>(B)?(A):(B))  //最大值
#define min(A,B) ((A)<(B)?(A):(B))  //最小值

#define PI 3.14159  //圆周率

//========================================================================
//                                头文件
//========================================================================

//#include "STC32G.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>              //标准整数类型头文件
//#include <intrins.h>             //汇编相关头文件
#include <math.h>                //数学相关头文件
#include "string.h"		         //字符串相关头文件
//#include "GPIO.h"								 //GPI0相关操作函数头文件
//#include "PIT.h"
//#include "Delay.h"
#include "systick_utils.h"
//#include "INT.h"
//#include "UART.h"
//#include "IIC.h"
//#include "PWM.h"
//#include "ADC.h"
//#include "usb.h"
//#include "M_string.h"
// #include "can.h"
#include "can.h"     // 启用CAN驱动
//#include "MKS.h"
//#include "SPI.h"   //A1机械臂控制函数库
//#include "DMA.h"   //D2地盘控制函数库
#include "eeprom_emulation_type_a.h"
#include "oled.h"
#include "mpu6050.h"

////========================================================================
////                            引脚和宏定义
////========================================================================

#define PWR_ADC_R1 94.16
#define PWR_ADC_R2 10.0
#define PWR_ADC_K ((PWR_ADC_R1+PWR_ADC_R2)/PWR_ADC_R2)

#define CAN_PORT 2  //CAN端口


////========================================================================
////                            外部函数和变量声明
////========================================================================
extern void System_init(void);  //系统初始化
extern void Usb_Rst(void);
extern void Key_Rst(void);
extern void set_clk(void);
	
extern uint8_t BCD2HEX(uint8_t val);
extern uint8_t HEX2BCD(uint8_t val);
extern long Limit_int(long min,long num,long max); //整数限幅函数
extern float Limit_float(float min,float num,float max);//浮点限幅函数
extern float sq(float num);  //平方函数

extern uint32_t sys_clk;
extern volatile uint32_t msTicks; // millisecond tick, incremented from SysTick
extern uint16_t MOTOR_state;
extern char USB_flag;

union float_uchar;
union long_uchar;
union int_uchar;	
union char_uchar;	


#endif //__CONFIG_H